package simpleTaskDispatcher.model;

public class DispatchingChange {

	final TaskQueue from;
	
	final TaskQueue to;
	
	final int workers;
	
	private DispatchingChange(TaskQueue from, TaskQueue to, int workers) {
		this.from = from;
		this.to = to;
		this.workers = workers;
	}
	
	public static DispatchingChange release(TaskQueue from, int workers) {
		return new DispatchingChange(from, null, workers);
	}
	
	public static DispatchingChange assign(TaskQueue to, int workers) {
		return new DispatchingChange(null, to, workers);
	}
	
	public static DispatchingChange transfert(TaskQueue from, TaskQueue to, int workers) {
		return new DispatchingChange(from, to, workers);
	}
	
	@Override
	public String toString() {
		if (from == null) {
			return "Give " + workers + " to " + to.getName();
			
		} else if (to == null) {
			return "Take " + workers + " from " + from.getName();
			
		} else {
			return "Take " + workers + " from " + from.getName() + ", gives them to " + to.getName();
		}
	}
	
}
